import { IsArray, IsNotEmpty } from 'class-validator';
import { ApiProperty, PickType } from '@nestjs/swagger';

class RoleAuthDto {
  @ApiProperty({ description: '角色ID' })
  @IsNotEmpty({ message: '角色ID不能为空' })
  fRoleId: string;

  @ApiProperty({ description: '权限ID' })
  @IsNotEmpty({ message: '权限ID不能为空' })
  @IsArray()
  fAuthArray: Array<any>;
}

class UpdateAuthDto {
  @ApiProperty({ description: '权限ID' })
  @IsNotEmpty({ message: '权限ID不能为空' })
  fAuthId: string;

  @ApiProperty({ description: '权限名称' })
  @IsNotEmpty({ message: '权限名称不能为空' })
  fAuthName: string;

  @ApiProperty({ description: '链接地址' })
  fAuthUrl: string;

  @ApiProperty({ description: '排序值' })
  fAuthSort: string;
}

class AddAuthDto extends PickType(UpdateAuthDto, ['fAuthName', 'fAuthUrl']) {
  @ApiProperty({ description: '父级ID' })
  @IsNotEmpty({ message: '父级ID不能为空' })
  fPId: string;
}

class DeleteAuth extends PickType(UpdateAuthDto, ['fAuthId']) {}

export { RoleAuthDto, UpdateAuthDto, AddAuthDto, DeleteAuth };
